/**
 * creater:chuanpeng.zhu@dhc.com.cn
 * create time:2016-05-31 09:07:17
 * describe:地址选择样例
 */
APP.controller('AreaExampleController', ['$scope', 'AreaExampleService', '$state', '$rootScope',
  function ($scope, AreaExampleService, $state, $rootScope) {

    /***变量声明***/
    var AREA_EXAMPLE = 'AREA_EXAMPLE';
    $scope.province = '请选择省市区信息';
    $scope.city = undefined;
    $scope.county = undefined;

    /**
     * 初始化函数
     */
    $scope.init = function () {

    };

    /**
     * 选择省市区方法
     */
    $scope.goSelectArea = function () {
      var param = {
        flag: AREA_EXAMPLE
      };
      $state.go('area', param);
    };
    $rootScope.$on(AREA_EXAMPLE, function (event, data) {
      console.log(data);
      $scope.province = data['text-1'];
      $scope.city = data['text-2'];
      $scope.county = data['text-3'];
    });

    /*
     $scope.init();//如果页面缓存则用此方法初始化
     */
    $scope.$on('$ionicView.beforeEnter', function () {
      $scope.init();
    });
  }
]);

/**
 * creater:chuanpeng.zhu@dhc.com.cn
 * create time:2016-05-31 09:07:17
 * describe:地址选择样例
 */
APP.service('AreaExampleService', ['$http', 'UrlService', function ($http, UrlService) {
  /**
   * 登录方法
   * @param username  登录用户名
   * @param password  登录密码
   */
  this.doLogin = function (username, password) {
    var param = {
      username: username,
      password: password
    };
    $http.post(UrlService.get('LOGIN'), param);
  }

}]);
